//
//  weightCollectionViewCell.m
//  Shine
//
//  Created by 俞青武 on 16/3/11.
//  Copyright © 2016年 王斌. All rights reserved.
//

#import "weightCollectionViewCell.h"
#import "PNChart.h"


@implementation weightCollectionViewCell

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    self.backgroundColor = COLORBLACK;
    self.WeightLabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH_SCREEN *0.1, 0, WIDTH_SCREEN *0.3, WIDTH_SCREEN *0.3)];
    self.WeightLabel.font = [UIFont systemFontOfSize:20];
    self.WeightLabel.textAlignment = NSTextAlignmentCenter;
    self.WeightLabel.textColor = COLORWHITE;
    [self addSubview:self.WeightLabel];
    
    
    self.BMILabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH_SCREEN *0.55, 0, WIDTH_SCREEN *0.3, WIDTH_SCREEN *0.3)];
    self.BMILabel.textAlignment = NSTextAlignmentCenter;
    self.BMILabel.font = [UIFont systemFontOfSize:20];
    self.BMILabel.textColor = COLORWHITE;
    [self addSubview:self.BMILabel];
    
    
    self.WeightNumber = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH_SCREEN *0.05, WIDTH_SCREEN *0.08, WIDTH_SCREEN *0.4, WIDTH_SCREEN *0.4)];
    self.WeightNumber.textAlignment = NSTextAlignmentCenter;
    self.WeightNumber.font = [UIFont systemFontOfSize:38];
    self.WeightNumber.textColor = COLORYELLO;
    [self addSubview:self.WeightNumber];
    
    self.BMINumber = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH_SCREEN *0.5, WIDTH_SCREEN *0.08, WIDTH_SCREEN *0.4, WIDTH_SCREEN *0.4)];
    self.BMINumber.textAlignment = NSTextAlignmentCenter;
    self.BMINumber.font = [UIFont systemFontOfSize:38];
    self.BMINumber.textColor = COLORYELLO;
    [self addSubview:self.BMINumber];
    
    
    
    self.lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(20, WIDTH_SCREEN *0.6, WIDTH_SCREEN - 40, WIDTH_SCREEN *0.8)];
    self.lineChart.yLabelFormat = @"%1.1f";
    self.lineChart.backgroundColor = [UIColor clearColor];
    self.lineChart.xLabelColor = [UIColor colorWithWhite:0.902 alpha:1.000];
    [self.lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
    
    
    self.lineChart.showCoordinateAxis = YES;
    
    //Use yFixedValueMax and yFixedValueMin to Fix the Max and Min Y Value
    //Only if you needed
    self.lineChart.yFixedValueMax = 300.0;
    self.lineChart.yFixedValueMin = 0.0;
    self.lineChart.yLabelColor = [UIColor colorWithWhite:0.902 alpha:1.000];
    [self.lineChart setYLabels:@[
                                 @"0 min",
                                 @"50 min",
                                 @"100 min",
                                 @"150 min",
                                 @"200 min",
                                 @"250 min",
                                 @"300 min",
                                 ]
     ];
    
    // Line Chart #1
    NSArray * data01Array = @[@60.1, @160.1, @126.4, @0.0, @186.2, @127.2, @176.2];
    PNLineChartData *data01 = [PNLineChartData new];
    data01.dataTitle = @"Alpha";
    data01.color = COLORYELLO;
    data01.alpha = 1;
    data01.itemCount = data01Array.count;
    data01.inflexionPointStyle = PNLineChartPointStyleCircle;
    
    data01.getData = ^(NSUInteger index) {
        CGFloat yValue = [data01Array[index] floatValue];
        return [PNLineChartDataItem dataItemWithY:yValue];
    };
    self.lineChart.chartData = @[data01];
    [self.lineChart strokeChart];
//    self.lineChart.delegate = self;
    
    
    [self addSubview:self.lineChart];


}


@end





















